package com.weasing.res.web.action;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.sf.json.JSONArray;

import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.weasing.res.domain.WxRegion;
import com.weasing.res.service.IWxRegionService;
import com.weasing.res.web.action.base.BaseAction;

@Controller
@Scope("prototype")
public class WxRegionAction extends BaseAction<WxRegion> {
	@Autowired
	private IWxRegionService wxRegionService;

	public void findWxRegionByCondition() {

		List<WxRegion> wxRegions = wxRegionService.findWxRegionByCondition(
				model.getParentId(), model.getRegionType());
		String json = JSONArray.fromObject(wxRegions).toString();
		ServletActionContext.getResponse().setContentType(
				"text/json;charset=utf-8");
		try {
			ServletActionContext.getResponse().getWriter().print(json);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
